import java.util.*;
import static java.lang.Math.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        String[] array = new String[n];
        for(int i = 0;i<n;i++){
            array[i] = sc.nextLine();
        }
        boolean flg1 = length(array,n);
        boolean flg2 = ordinary(array,n);
        if(flg1==true&&flg2!=true){
            System.out.println("lengths");
        }else if(flg1!=true&&flg2==true){
            System.out.println("lexicographically");
        }else if(flg1==true&&flg2==true){
            System.out.println("both");
        }else{
            System.out.println("none");
        }

    }
    public static boolean length(String[] array,int n){
        int i = 0;
        for(i = 0;i<n-1;i++){
            if(array[i].length()>array[i+1].length()){
                return false;
            }
        }
        return true;
    }
    public static boolean isordinary(String s1,String s2){
        int l = min(s1.length(),s2.length());
        for(int i = 0;i<l;i++){
            if(s1.charAt(i)<s2.charAt(i)){
                return true;
            }
            if(s1.charAt(i)>s2.charAt(i)){
                return false;
            }
        }
        if(s1.charAt(l-1)==s2.charAt(l-1)){
            if(s1.length()>s2.length()){
                return false;
            }
        }
        return true;
    }
    public static boolean ordinary(String[] array,int n){
        int k = 0;
        for(int i = 0;i<n-1;i++){
            if(isordinary(array[i],array[i+1])){
                k++;
                if(k==n-1){
                    return true;
                }
            }else{
                break;
            }
        }
        return false;
    }
}
